<template>
  <div>
    <input type="text" v-model="username" ref="input" />
    <input type="password" v-model="password" />
    <button @click="login">登录</button>
  </div>
</template>
<script>
import { mapMutations } from "vuex";
export default {
  name: "login",
  data() {
    return {
      username: "dsfsd",
      password: ""
    };
  },
  watch: {
    username(val, val2) {
      console.log(val, val2);
    }
  },
  mounted() {
    console.log(this.$refs.input.value);
  },
  methods: {
    ...mapMutations(["setAuth"]),
    login() {
      this.setAuth(this.username + this.password);
      this.$router.push("/home");
    }
  }
};
</script>
